from flask import Flask, render_template, request

app = Flask(__name__)

# 首页（显示表单）
@app.route("/", methods=["GET", "POST"])
def index():
    if request.method == "POST":
        # 获取表单数据
        username = request.form.get("username")
        password = request.form.get("password")
        print(username, password)
        print(f"收到数据：用户1名={username}, 密码={password}")
        return f"提1交成功！用1户名111: {username}"
    
    # GET 请求时渲染表单页面
    return render_template("form.html")

if __name__ == "__main__":
    app.run()